package real.yingke;

import java.util.*;

import real.yingke.IsPrink.Solution;

public class Calculator {
     /**
     * 计算器
     * @param s string字符串 公式
     * @return long长整型
     */
    public long calculate (String s) {
        int len;
        if (s == null || (len = s.length()) == 0) return 0;
        List<Integer>cals = new ArrayList<>();
        StringBuilder sb = new StringBuilder(s);
        int idx = 0;
        while (idx < sb.length()) {
            if (sb.charAt(idx) == ' ') {
                sb = sb.deleteCharAt(idx);
            } else {
                idx++;
            }
        }
        System.out.println(sb);
        for (int i = 0; i < sb.length(); i++) {
            if (sb.charAt(i) == '+' || sb.charAt(i) == '-' || sb.charAt(i) == '*' || sb.charAt(i) == '/') {
                cals.add(i);
            }
        }
        System.out.println(sb);
        List<Integer> nums = new ArrayList<>();
        nums.add(Integer.parseInt(sb.substring(0, cals.get(0))));
        int start = cals.get(0), end = cals.get(1);
        for (int i = 0; i < cals.size() - 1; i++) {
            start = cals.get(i) + 1;
            end = cals.get(i + 1);
            nums.add(Integer.parseInt(sb.substring(start, end)));
        }
        nums.add(Integer.parseInt(sb.substring(end + 1)));
        idx = 0;
        while (idx < cals.size()) {
            if (sb.charAt(cals.get(idx)) == '*' || sb.charAt(idx) == '/') {
                
            }
        }
        System.out.println(nums);
        return 0;
    }

    public static void main(String[] args) {
        Calculator c = new Calculator();
        c.calculate("1 + 3 / 2");

    }
}
